<?php

declare(strict_types=1);

namespace app\admin\controller\config;

use think\Request;
use think\Response;
use sheep\model\Config;
use sheep\controller\Backend;


class Basic extends Backend
{

    /**
     * 站点配置
     *
     * @return Response
     */
    public function site(Request $request): Response
    {
        if ('GET' === $request->method()) {

            $configs = Config::getConfigs('basic.site', false);
        } elseif ('PUT' === $request->method()) {

            $configs = Config::setConfigs('basic.site', $request->param());
        }
        return success('操作成功', $configs);
    }

    /**
     * 登录配置
     */
    public function login(Request $request): Response
    {
        if ('GET' === $request->method()) {

            $configs = Config::getConfigs('basic.login', false);
        } elseif ('PUT' === $request->method()) {

            $configs = Config::setConfigs('basic.login', $request->param());
        }
        return success('操作成功', $configs);
    }

    /**
     * 邮件配置
     */
    public function mail(Request $request): Response
    {
        if ('GET' === $request->method()) {

            $configs = Config::getConfigs('basic.mail', false);
        } elseif ('PUT' === $request->method()) {

            $configs = Config::setConfigs('basic.mail', $request->param());

        }
        return success('操作成功', $configs);
    }

    /**
     * 用户配置
     */
    public function user(Request $request): Response
    {
        if ('GET' === $request->method()) {

            $configs = Config::getConfigs('basic.user', false);
        } elseif ('PUT' === $request->method()) {

            $configs = Config::setConfigs('basic.user', $request->param());

        }
        return success('操作成功', $configs);
    }
}
